package com.design.访问者模式;

/**
 * @author: sun.hongliang
 * @create: 2019/09/16 16:49
 */
public class Computer implements ComputerPart {

    ComputerPart[] parts;

    public Computer() {
        parts = new ComputerPart[]{new Mouse(), new Keyboard(), new Monitor()};
    }

    @Override
    public void accept(ComputerPartVisitor computerPartVisitor) {

        for (int i = 0; i < parts.length; i++) {
            parts[i].accept(computerPartVisitor);
        }

        computerPartVisitor.visit(this);
    }
}
